package com.zb.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zb.entity.ZjStoreOutboundMaterial;
import com.zb.extend.StoreOutboundMaterialExtend;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * 出库物料表 Mapper 接口
 * </p>
 *
 * @author WEN
 * @since 2024-01-08
 */
@Repository
public interface ZjStoreOutboundMaterialMapper extends BaseMapper<ZjStoreOutboundMaterial> {

    /**
     * 根据出库ID更新出库的状态
     * @param outboundId 出库单ID
     */
    void updateStatusByOutbountId(@Param("outboundId") Long outboundId, @Param("status") Integer status);

    /**
     * 根据出库ID获取出库物料详情&即时库存
     * @param outboundId 出库ID
     * @return
     */
    List<StoreOutboundMaterialExtend> getOutboundMaterial(@Param("outboundId") Long outboundId);

    /**
     * 根据仓位ID分组统计预出库数量
     * @param storePositionIds 仓位ID
     * @return
     */
    List<ZjStoreOutboundMaterial> getOutStoreQtyGroupByStorePositionIds(@Param("storePositionIds")List<Long> storePositionIds);

    /**
     * 根据商品ID分组统计预入库数量
     * @param storeId 仓库ID
     * @param storePositionId 仓位ID
     * @param goodsIds 商品ID
     * @param goodsSpecIds 商品规格ID
     * @return
     */
    List<ZjStoreOutboundMaterial> getOutStoreQtyByStoreIdOrStorePositionIdAndGroupByGoodsId(@Param("storeId") Long storeId, @Param("storePositionId") Long storePositionId, @Param("goodsIds") List<Long> goodsIds, @Param("goodsSpecIds") List<Long> goodsSpecIds);

    /**
     * 根据仓库ID分组统计预出库数量
     * @param storeIds 仓库ID
     * @param goodsIds 商品ID
     * @param goodsSpecIds 商品规格ID
     * @return
     */
    List<ZjStoreOutboundMaterial> getOutStoreQtyByStoreIdGroupByStoreId(@Param("storeIds") List<Long> storeIds, @Param("goodsIds") List<Long> goodsIds, @Param("goodsSpecIds") List<Long> goodsSpecIds);
}
